package exchange;

import java.util.LinkedList;

public class Solution {
    public int[] exchange(int[] nums) {
        // 双指针
        int i = 0,j = nums.length-1;
        while (i<j) {
            if(nums[i]%2!=0) {
                i++;
            }else if(nums[j]%2==0) {
                j--;
            }else {
                int t = nums[i];
                nums[i] = nums[j];
                nums[j] = t;
                i++;
                j--;
            }
        }


        return nums;
    }
}
